home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Power 1997 December
/
MACPOWER-1997-12.ISO.7z
/
MACPOWER-1997-12.ISO
/
AMUG
/
PROGRAMMING
/
Raven 1.2.sit
/
Raven 1.2
/
Source
/
Foundation
/
Common
/
ZGeometry.h
< prev
next >
Wrap
Text File
|
1997-07-24
|
25KB
|
823 lines
/*
* File: ZGeometry.h
* Summary: Point, size, and rectangle classes.
* Written by: Jesse Jones
*
* Copyright ゥ 1996-1997 Jesse Jones.
* For conditions of distribution and use, see copyright notice in ZTypes.h
*
* Change History (most recent first):
*
* <7> 5/29/97 JDJ Added TPoint and TLongPoint Distance friend functions.
* <6> 5/17/97 JDJ TPoint and TLongPoint operator <, <=, >, and >=
* check v first.
* <5> 3/31/97 JDJ Added SetWidth and SetHeight to rect classes.
* <4> 3/30/97 JDJ Added <, <=, >, and >= operators to TPoint.
* <3> 3/26/97 JDJ Added specializations of STL's copy, copy_backward,
* and uninitialized_copy functions.
* <2> 3/11/97 JDJ Made Pin methods const.
* <1> 1/14/96 JDJ Created.
*/
#pragma once
#include <Fp.h>
#include <ZDebug.h>
#include <ZTypes.h>
//-----------------------------------
// Forward References
//
class TPoint;
class TSize;
class TRect;
class TLongPoint;
class TLongSize;
class TLongRect;
// ===================================================================================
// class TPoint
// ===================================================================================
class TPoint {
//-----------------------------------
// Initialization/Destruction
//
public:
TPoint() {}
TPoint(short inX, short inY) {h = inX; v = inY;}
TPoint(const Point& rhs) {h = rhs.h; v = rhs.v;}
//-----------------------------------
// Conversion operators
//
public:
operator Point() const {return *(const Point *) this;}
operator Point*() {return (Point *) this;}
//-----------------------------------
// Arithmetic operators
//
public:
TPoint operator-() const {return TPoint((short) (-h), (short) (-v));}
TPoint operator+(const TPoint& rhs) const {return TPoint((short) (h + rhs.h), (short) (v + rhs.v));}
TPoint operator+(const TSize& rhs) const;
TPoint operator-(const TPoint& rhs) const {return TPoint((short) (h - rhs.h), (short) (v - rhs.v));}
TPoint operator-(const TSize& rhs) const;
TPoint operator*(short num) const {return TPoint((short) (h*num), (short) (v*num));}
friend TPoint operator*(short num, const TPoint& rhs);
TPoint operator/(short num) const {ASSERT(num != 0); return TPoint((short) (h/num), (short) (v/num));}
TPoint& operator+=(const TPoint& rhs);
TPoint& operator+=(const TSize& rhs);
TPoint& operator-=(const TPoint& rhs);
TPoint& operator-=(const TSize& rhs);
//-----------------------------------
// Relational Operators
//
public:
bool operator==(const TPoint& rhs) const {return h == rhs.h && v == rhs.v;}
bool operator!=(const TPoint& rhs) const {return h != rhs.h || v != rhs.v;}
bool operator<(const TPoint& rhs) const {return v < rhs.v || (v == rhs.v && h < rhs.h);}
bool operator<=(const TPoint& rhs) const {return v < rhs.v || (v == rhs.v && h <= rhs.h);}
bool operator>(const TPoint& rhs) const {return v > rhs.v || (v == rhs.v && h > rhs.h);}
bool operator>=(const TPoint& rhs) const {return v > rhs.v || (v == rhs.v && h >= rhs.h);}
//-----------------------------------
// Misc
//
public:
friend double Distance(const TPoint& pt1, const TPoint& pt2) {return sqrt((float) (pt1.h - pt2.h)*(pt1.h - pt2.h) + (float) (pt1.v - pt2.v)*(pt1.v - pt2.v));}
//-----------------------------------
// Member data
//
public:
short v;
short h;
};
// ===================================================================================
// class TSize
// ===================================================================================
class TSize {
//-----------------------------------
// Initialization/Destruction
//
public:
TSize() {}
TSize(short inWidth, short inHeight) {width = inWidth; height = inHeight;}
//-----------------------------------
// Conversion operators
//
public:
operator Point() const {return *(const Point *) this;}
operator Point*() {return (Point*) this;}
//-----------------------------------
// Arithmetic operators
//
public:
TSize operator-() const {return TSize((short) (-width), (short) (-height));}
TSize operator+(const TSize& rhs) const {return TSize((short) (width + rhs.width), (short) (height + rhs.height));}
TSize operator-(const TSize& rhs) const {return TSize((short) (width - rhs.width), (short) (height - rhs.height));}
TSize operator*(short num) const {return TSize((short) (width*num), (short) (height*num));}
friend TSize operator*(short num, const TSize& rhs);
TSize operator/(short num) const {ASSERT(num != 0); return TSize((short) (width/num), (short) (height/num));}
TSize& operator+=(const TSize& rhs);
TSize& operator-=(const TSize& rhs);
//-----------------------------------
// Relational Operators
//
public:
bool operator==(const TSize& rhs) const {return width == rhs.width && height == rhs.height;}
bool operator!=(const TSize& rhs) const {return width != rhs.width || height != rhs.height;}
//-----------------------------------
// Misc
//
public:
long GetArea() const {return (long) width * height;}
//-----------------------------------
// Member data
//
public:
short height;
short width;
};
// ===================================================================================
// class TRect
// ===================================================================================
enum PointSelector {topLeft, botRight};
class TRect : public Rect {
//-----------------------------------
// Initialization/Destruction
//
public:
TRect() {}
TRect(short inLeft, short inTop, short inRight, short inBottom) {left = inLeft; top = inTop; right = inRight; bottom = inBottom;}
TRect(const TPoint& topLeftPt, const TPoint& botRightPt);
TRect(const TPoint& topLeftPt, const TSize& size);
TRect(const Rect& rect);
//-----------------------------------
// Conversion operators
//
public:
operator const Rect*() const {return (const Rect *) this;}
operator Rect*() {return (Rect *) this;}
//-----------------------------------
// Dimensions
//
public:
short GetWidth() const {return (short) (right - left);}
short GetHeight() const {return (short) (bottom - top);}
TSize GetSize() const {return TSize((short) (right - left), (short) (bottom - top));}
long GetArea() const {return ((long) (right - left) * (bottom - top));}
//-----------------------------------
// Selectors
//
public:
TPoint& operator[](PointSelector sel) {return (sel == topLeft) ? (*((TPoint *)&top)) : (*((TPoint *)&bottom));}
const TPoint& operator[](PointSelector sel) const {return (sel == topLeft) ? (*((const TPoint *)&top)) : (*((const TPoint *)&bottom));}
//-----------------------------------
// Operations
//
public:
void MoveTo(const TPoint& pt);
void MoveBy(const TPoint& pt);
TRect operator+(const TPoint& rhs) const {return TRect((short) (left + rhs.h), (short) (top + rhs.v), (short) (right + rhs.h), (short) (bottom + rhs.v));}
TRect operator+(const TSize& rhs) const {return TRect((short) (left + rhs.width), (short) (top + rhs.height), (short) (right + rhs.width), (short) (bottom + rhs.height));}
TRect operator-(const TPoint& rhs) const {return TRect((short) (left - rhs.h), (short) (top - rhs.v), (short) (right - rhs.h), (short) (bottom - rhs.v));}
TRect operator-(const TSize& rhs) const {return TRect((short) (left - rhs.width), (short) (top - rhs.height), (short) (right - rhs.width), (short) (bottom - rhs.height));}
TRect operator&(const TRect& rhs) const;
TRect operator|(const TRect& rhs) const;
TRect& operator+=(const TPoint& rhs);
TRect& operator+=(const TSize& rhs);
TRect& operator-=(const TPoint& rhs);
TRect& operator-=(const TSize& rhs);
TRect& operator&=(const TRect& rhs);
TRect& operator|=(const TRect& rhs);
void Inset(const TPoint& delta);
void Inset(short dx, short dy);
void SetWidth(short size) {right = (short) (left + size);}
void SetHeight(short size) {bottom = (short) (top + size);}
void SetSize(const TSize& size) {right = (short) (left + size.width); bottom = (short) (top + size.height);}
//-----------------------------------
// Relational Operators
//
public:
bool operator==(const TRect& rhs) const {return (left == rhs.left && right == rhs.right && top == rhs.top && bottom == rhs.bottom);}
bool operator!=(const TRect& rhs) const {return (!(*this == rhs));}
//-----------------------------------
// Misc
//
public:
bool Contains(const TPoint& pt) const {return (pt.v >= top && pt.v < bottom && pt.h >= left && pt.h < right);}
// Returns true if pt is within the rectangle.
bool Contains(const TRect& rect) const {return (rect.top >= top && rect.bottom <= bottom && rect.left >= left && rect.right <= right);}
bool Intersects(const TRect& rect) const {return (left <= rect.right && right >= rect.left && top <= rect.bottom && bottom >= rect.top);}
// Return true if the rectangle intersects rect.
bool IsEmpty() const {return left >= right || top >= bottom;}
// Returns true if width or height are zero.
void MakeEmpty() {left = right = top = bottom = 0;}
// Empties the rectangle.
void CenterIn(const TRect& container);
// Center the rectangle in the container.
void MapTo(const TRect& container, double maxScaleFactor = 1.0);
// Scales the rectangle so that it's within the container and
// its size is as close as possible to the container's size.
// Note that this preserves the rectangle's aspect ratio and
// won't blow up the rectangle by an amount larger than
// maxScaleFactor.
TPoint Pin(const TPoint& pt) const;
// Returns the point within the rectangle closest to pt.
};
// ===================================================================================
// class TLongPoint
// ===================================================================================
class TLongPoint {
//-----------------------------------
// Initialization/Destruction
//
public:
TLongPoint() {}
TLongPoint(const TPoint& rhs) {h = rhs.h; v = rhs.v;}
TLongPoint(long inX, long inY) {h = inX; v = inY;}
//-----------------------------------
// Arithmetic operators
//
public:
TLongPoint operator-() const {return TLongPoint(-h, -v);}
TLongPoint operator+(const TLongPoint& rhs) const {return TLongPoint(h + rhs.h, v + rhs.v);}
TLongPoint operator+(const TLongSize& rhs) const;
TLongPoint operator-(const TLongPoint& rhs) const {return TLongPoint(h - rhs.h, v - rhs.v);}
TLongPoint operator-(const TLongSize& rhs) const;
TLongPoint operator*(long num) const {return TLongPoint(h*num, v*num);}
friend TLongPoint operator*(long num, const TLongPoint& rhs);
TLongPoint operator/(long num) const {ASSERT(num != 0); return TLongPoint(h/num, v/num);}
TLongPoint& operator+=(const TLongPoint& rhs);
TLongPoint& operator+=(const TLongSize& rhs);
TLongPoint& operator-=(const TLongPoint& rhs);
TLongPoint& operator-=(const TLongSize& rhs);
//-----------------------------------
// Relational Operators
//
public:
bool operator==(const TLongPoint& rhs) const {return (h == rhs.h && v == rhs.v);}
bool operator!=(const TLongPoint& rhs) const {return (h != rhs.h || v != rhs.v);}
bool operator<(const TLongPoint& rhs) const {return v < rhs.v || (v == rhs.v && h < rhs.h);}
bool operator<=(const TLongPoint& rhs) const {return v < rhs.v || (v == rhs.v && h <= rhs.h);}
bool operator>(const TLongPoint& rhs) const {return v > rhs.v || (v == rhs.v && h > rhs.h);}
bool operator>=(const TLongPoint& rhs) const {return v > rhs.v || (v == rhs.v && h >= rhs.h);}
//-----------------------------------
// Misc
//
public:
friend double Distance(const TLongPoint& pt1, const TLongPoint& pt2) {return sqrt((float) (pt1.h - pt2.h)*(pt1.h - pt2.h) + (float) (pt1.v - pt2.v)*(pt1.v - pt2.v));}
//-----------------------------------
// Member data
//
public:
long v;
long h;
};
// ===================================================================================
// class TLongSize
// ===================================================================================
class TLongSize {
//-----------------------------------
// Initialization/Destruction
//
public:
TLongSize() {}
TLongSize(const TSize& rhs) {width = rhs.width; height = rhs.height;}
TLongSize(long inWidth, long inHeight) {width = inWidth; height = inHeight;}
//-----------------------------------
// Arithmetic operators
//
public:
TLongSize operator-() const {return TLongSize(-width, -height);}
TLongSize operator+(const TLongSize& rhs) const {return TLongSize(width + rhs.width, height + rhs.height);}
TLongSize operator-(const TLongSize& rhs) const {return TLongSize(width - rhs.width, height - rhs.height);}
TLongSize operator*(long num) const {return TLongSize(width*num, height*num);}
friend TLongSize operator*(long num, const TLongSize& rhs);
TLongSize operator/(long num) const {ASSERT(num != 0); return TLongSize(width/num, height/num);}
TLongSize& operator+=(const TLongSize& rhs);
TLongSize& operator-=(const TLongSize& rhs);
//-----------------------------------
// Relational Operators
//
public:
bool operator==(const TLongSize& rhs) const {return width == rhs.width && height == rhs.height;}
bool operator!=(const TLongSize& rhs) const {return width != rhs.width || height != rhs.height;}
//-----------------------------------
// Misc
//
public:
long GetArea() const {return width * height;}
//-----------------------------------
// Member data
//
public:
long height;
long width;
};
// ===================================================================================
// class TLongRect
// ===================================================================================
class TLongRect {
//-----------------------------------
// Initialization/Destruction
//
public:
TLongRect() {}
TLongRect(long inLeft, long inTop, long inRight, long inBottom) {left = inLeft; top = inTop; right = inRight; bottom = inBottom;}
TLongRect(const TLongPoint& topLeftPt, const TLongPoint& botRightPt);
TLongRect(const TLongPoint& topLeftPt, const TLongSize& size);
TLongRect(const TRect& rhs) {left = rhs.left; right = rhs.right; top = rhs.top; bottom = rhs.bottom;}
//-----------------------------------
// Dimensions
//
public:
long GetWidth() const {return right - left;}
long GetHeight() const {return bottom - top;}
TLongSize GetSize() const {return TLongSize(right - left, bottom - top);}
long GetArea() const {return (right - left)*(bottom - top);}
//-----------------------------------
// Selectors
//
public:
TLongPoint& operator[](PointSelector sel) {return (sel == topLeft) ? (*((TLongPoint *)&top)) : (*((TLongPoint *)&bottom));}
const TLongPoint& operator[](PointSelector sel) const {return (sel == topLeft) ? (*((const TLongPoint *)&top)) : (*((const TLongPoint *)&bottom));}
//-----------------------------------
// Operations
//
public:
void MoveTo(const TLongPoint& pt);
void MoveBy(const TLongPoint& pt);
TLongRect operator+(const TLongPoint& rhs) const {return TLongRect(left + rhs.h, top + rhs.v, right + rhs.h, bottom + rhs.v);}
TLongRect operator+(const TLongSize& rhs) const {return TLongRect(left + rhs.width, top + rhs.height, right + rhs.width, bottom + rhs.height);}
TLongRect operator-(const TLongPoint& rhs) const {return TLongRect(left - rhs.h, top - rhs.v, right - rhs.h, bottom - rhs.v);}
TLongRect operator-(const TLongSize& rhs) const {return TLongRect(left - rhs.width, top - rhs.height, right - rhs.width, bottom - rhs.height);}
TLongRect operator&(const TLongRect& rhs) const;
TLongRect operator|(const TLongRect& rhs) const;
TLongRect& operator+=(const TLongPoint& rhs);
TLongRect& operator+=(const TLongSize& rhs);
TLongRect& operator-=(const TLongPoint& rhs);
TLongRect& operator-=(const TLongSize& rhs);
TLongRect& operator&=(const TLongRect& rhs);
TLongRect& operator|=(const TLongRect& rhs);
void Inset(const TLongPoint& delta);
void Inset(long dx, long dy);
void SetWidth(long size) {right = left + size;}
void SetHeight(long size) {bottom = top + size;}
void SetSize(const TLongSize& size) {right = left + size.width; bottom = top + size.height;}
//-----------------------------------
// Relational Operators
//
public:
bool operator==(const TLongRect& rhs) const {return (left == rhs.left && right == rhs.right && top == rhs.top && bottom == rhs.bottom);}
bool operator!=(const TLongRect& rhs) const {return (!(*this == rhs));}
//-----------------------------------
// Misc
//
public:
bool Contains(const TLongPoint& pt) const {return (pt.v >= top && pt.v < bottom && pt.h >= left && pt.h < right);}
// Returns true if pt is within the rectangle.
bool Contains(const TLongRect& rect) const {return (rect.top >= top && rect.bottom <= bottom && rect.left >= left && rect.right <= right);}
bool Intersects(const TLongRect& rect) const {return (left <= rect.right && right >= rect.left && top <= rect.bottom && bottom >= rect.top);}
// Return true if the rectangle intersects rect.
bool IsEmpty() const {return left >= right || top >= bottom;}
// Returns true if width or height are zero.
void MakeEmpty() {left = right = top = bottom = 0;}
// Empties the rectangle.
void CenterIn(const TLongRect& container);
// Center the rectangle in the container.
void MapTo(const TRect& container, double maxScaleFactor = 1.0);
// Scales the rectangle so that it's within the container and
// its size is as close as possible to the container's size.
// Note that this preserves the rectangle's aspect ratio and
// won't blow up the rectangle by an amount larger than
// maxScaleFactor.
TLongPoint Pin(const TLongPoint& pt) const;
// Returns the point within the rectangle closest to pt.
//-----------------------------------
// Member data
//
public:
long top;
long left;
long bottom;
long right;
};
//-----------------------------------
// Constants
//
extern const TPoint kZeroPt;
extern const TSize kZeroSize;
extern const TRect kZeroRect;
extern const TLongPoint kLongZeroPt;
extern const TLongSize kLongZeroSize;
extern const TLongRect kLongZeroRect;
// ===================================================================================
// STL specializations
// ===================================================================================
DECLARE_STL_FUNCTIONS(TPoint);
DECLARE_STL_FUNCTIONS(TSize);
DECLARE_STL_FUNCTIONS(TRect);
DECLARE_STL_FUNCTIONS(TLongPoint);
DECLARE_STL_FUNCTIONS(TLongSize);
DECLARE_STL_FUNCTIONS(TLongRect);
// ===================================================================================
// Inlines
// ===================================================================================
inline TPoint TPoint::operator-(const TSize& rhs) const
{
return TPoint((short) (h - rhs.width), (short) (v - rhs.height));
}
inline TPoint TPoint::operator+(const TSize& rhs) const
{
return TPoint((short) (h + rhs.width), (short) (v + rhs.height));
}
inline TPoint& TPoint::operator+=(const TPoint& rhs)
{
h += rhs.h;
v += rhs.v;
return *this;
}
inline TPoint& TPoint::operator-=(const TPoint& rhs)
{
h -= rhs.h;
v -= rhs.v;
return *this;
}
inline TPoint& TPoint::operator+=(const TSize& rhs)
{
h += rhs.width;
v += rhs.height;
return *this;
}
inline TPoint& TPoint::operator-=(const TSize& rhs)
{
h -= rhs.width;
v -= rhs.height;
return *this;
}
#pragma mark -
inline TSize& TSize::operator+=(const TSize& rhs)
{
width += rhs.width;
height += rhs.height;
return *this;
}
inline TSize& TSize::operator-=(const TSize& rhs)
{
width -= rhs.width;
height -= rhs.height;
return *this;
}
#pragma mark -
inline TRect::TRect(const TPoint& topLeftPt, const TPoint& botRightPt)
{
left = topLeftPt.h;
top = topLeftPt.v;
right = botRightPt.h;
bottom = botRightPt.v;
}
inline TRect::TRect(const TPoint& topLeftPt, const TSize& size)
{
left = topLeftPt.h;
top = topLeftPt.v;
right = (short) (topLeftPt.h + size.width);
bottom = (short) (topLeftPt.v + size.height);
}
inline TRect::TRect(const Rect& rect)
{
left = rect.left;
top = rect.top;
right = rect.right;
bottom = rect.bottom;
}
inline void TRect::MoveBy(const TPoint& pt)
{
left += pt.h;
top += pt.v;
right += pt.h;
bottom += pt.v;
}
inline void TRect::MoveTo(const TPoint& pt)
{
this->MoveBy(TPoint((short) (pt.h - left), (short) (pt.v - top)));
}
inline void TRect::Inset(short dx, short dy)
{
top += dy;
left += dx;
bottom -= dy;
right -= dx;
}
inline void TRect::Inset(const TPoint& delta)
{
this->Inset(delta.h, delta.v);
}
inline TRect& TRect::operator&=(const TRect& rhs)
{
*this = *this & rhs;
return *this;
}
inline TRect& TRect::operator|=(const TRect& rhs)
{
*this = *this | rhs;
return *this;
}
inline TRect& TRect::operator+=(const TPoint& rhs)
{
this->MoveBy(rhs);
return *this;
}
inline TRect& TRect::operator-=(const TPoint& rhs)
{
this->MoveBy(-rhs);
return *this;
}
inline TRect& TRect::operator+=(const TSize& rhs)
{
this->MoveBy(TPoint(rhs.width, rhs.height));
return *this;
}
inline TRect& TRect::operator-=(const TSize& rhs)
{
this->MoveBy(TPoint((short) (-rhs.width), (short) (-rhs.height)));
return *this;
}
inline void TRect::CenterIn(const TRect& container)
{
this->MoveTo(container[topLeft] + (container.GetSize() - GetSize()) / 2);
}
#pragma mark -
inline TLongPoint TLongPoint::operator+(const TLongSize& rhs) const
{
return TLongPoint(h + rhs.width, v + rhs.height);
}
inline TLongPoint TLongPoint::operator-(const TLongSize& rhs) const
{
return TLongPoint(h - rhs.width, v - rhs.height);
}
inline TLongPoint& TLongPoint::operator+=(const TLongPoint& rhs)
{
h += rhs.h;
v += rhs.v;
return *this;
}
inline TLongPoint& TLongPoint::operator-=(const TLongPoint& rhs)
{
h -= rhs.h;
v -= rhs.v;
return *this;
}
inline TLongPoint& TLongPoint::operator+=(const TLongSize& rhs)
{
h += rhs.width;
v += rhs.height;
return *this;
}
inline TLongPoint& TLongPoint::operator-=(const TLongSize& rhs)
{
h -= rhs.width;
v -= rhs.height;
return *this;
}
#pragma mark -
inline TLongSize& TLongSize::operator+=(const TLongSize& rhs)
{
width += rhs.width;
height += rhs.height;
return *this;
}
inline TLongSize& TLongSize::operator-=(const TLongSize& rhs)
{
width -= rhs.width;
height -= rhs.height;
return *this;
}
#pragma mark -
inline TLongRect::TLongRect(const TLongPoint& topLeftPt, const TLongPoint& botRightPt)
{
left = topLeftPt.h;
top = topLeftPt.v;
right = botRightPt.h;
bottom = botRightPt.v;
}
inline TLongRect::TLongRect(const TLongPoint& topLeftPt, const TLongSize& size)
{
left = topLeftPt.h;
top = topLeftPt.v;
right = topLeftPt.h + size.width;
bottom = topLeftPt.v + size.height;
}
inline void TLongRect::Inset(long dx, long dy)
{
top += dy;
left += dx;
bottom -= dy;
right -= dx;
}
inline void TLongRect::Inset(const TLongPoint& delta)
{
this->Inset(delta.h, delta.v);
}
inline void TLongRect::MoveBy(const TLongPoint& rhs)
{
left += rhs.h;
top += rhs.v;
right += rhs.h;
bottom += rhs.v;
}
inline void TLongRect::MoveTo(const TLongPoint& pt)
{
this->MoveBy(TLongPoint(pt.h - left, pt.v - top));
}
inline TLongRect& TLongRect::operator&=(const TLongRect& rhs)
{
*this = *this & rhs;
return *this;
}
inline TLongRect& TLongRect::operator|=(const TLongRect& rhs)
{
*this = *this | rhs;
return *this;
}
inline TLongRect& TLongRect::operator+=(const TLongPoint& rhs)
{
this->MoveBy(rhs);
return *this;
}
inline TLongRect& TLongRect::operator-=(const TLongPoint& rhs)
{
this->MoveBy(-rhs);
return *this;
}
inline TLongRect& TLongRect::operator+=(const TLongSize& rhs)
{
this->MoveBy(TLongPoint(rhs.width, rhs.height));
return *this;
}
inline TLongRect& TLongRect::operator-=(const TLongSize& rhs)
{
this->MoveBy(TLongPoint(-rhs.width, -rhs.height));
return *this;
}
inline void TLongRect::CenterIn(const TLongRect& container)
{
this->MoveTo(container[topLeft] + (container.GetSize() - GetSize()) / 2);
}